% Calibrating beta and delta

clc
clear all

w=ones(26,2); % no wage differentials
load moments_from_Seoul_survey.mat
load distance_GIS.mat
load calibrated_E.mat
load initial_infection.mat

epsilon_weekday=4.1642;
epsilon_weekend=4.9144;
kappa=0.0339;

H_R(:,1)=H_R_young; % young
H_R(:,2)=H_R_old;   % old

ncity=25;

gamma=1/18; % 18 days to be recovered
tau=[1/8.5 1/10.2]; % days to be quaurantined
death_rate=[0.0021 0.0273]; % fatality rate

delta_t=zeros(2,2);

delta_j(:,1)=[0.00466524182 0.0077265261 0.00466524182 0.0077265261]'; % young, weekday case/visit weekend case/visit
delta_j(:,2)=[0.00621917775 0.01046068872 0.00621917775 0.01046068872]'; % old, weekday case/visit weekend case/visit

global w d_GIS ncity epsilon_weekday epsilon_weekend kappa E_weekday E_weekend H_R initial_infection gamma tau death_rate delta_j delta_t

%% beta, d_I, delta's
guess = [0.15044 0.01634];
% beta d_I
LBD=zeros(1,2);
eps=10^-5;
options = psoptimset('Display','iter','TolFun',eps,'TolX',eps);
[x,ll,exitflag,output] = patternsearch(@Calibrate_beta_d_I_function,guess,[],[],[],[],LBD,[],[],options);
x
